package com.lqs.dataservice.Service;

import com.lqs.dataservice.constants.MessageConstants;
import com.lqs.dataservice.dao.RepEvaluateDao;
import com.lqs.dataservice.entity.RepEvaluate;
import com.nip.db.mongodb.utils.tips.Response;
import com.nip.db.mongodb.utils.tips.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * ArmyService
 *
 * @author < a href=" ">BBB</ a>
 * @version v1.0.01
 * @date 2019-12-27 14:41
 */
@Service
public class RepEvaluateService {
    @Autowired
    RepEvaluateDao repEvaluateDao;

    public List<RepEvaluate> findAllByRepId(String repId){
        return repEvaluateDao.findAllByRepId(repId);
    }

    public Response saveRepEvaluate(RepEvaluate entity) {
        try {
            repEvaluateDao.save(entity);
            return new Response(ResponseCode.CODE_200, MessageConstants.SUCCESS);
        } catch (Exception e) {
            return new Response(ResponseCode.CODE_202, e.getMessage());
        }
    }

    public Response deleteRepEvaluateById(String id) {
        try {
            repEvaluateDao.deleteById(id);
            return new Response(ResponseCode.CODE_200, MessageConstants.SUCCESS);
        } catch (Exception e) {
            return new Response(ResponseCode.CODE_202, e.getMessage());
        }
    }
}
